package com.chen.blog.service.impl;

import com.chen.blog.mapper.ArticleMapper;
import com.chen.blog.pojo.Article;
import com.chen.blog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author cgj
 * @date 1/20/25 11:01 AM
 */
@Service
@Transactional
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleMapper articleMapper;
    @Transactional(readOnly = true)
    @Override
    public List<Article> showAllByArticle(Article article) {
        return articleMapper.selectAllByArticle(article);
    }

    @Override
    @Transactional(readOnly = true)
    public Article showArticleById(Integer id) {
        return articleMapper.selectArticleById(id);
    }

    @Override
    @Transactional(readOnly = true)
    public List<Article> showArticleByUid(Integer uid) {
        return articleMapper.selectArticlesByUid(uid);
    }

    @Override
    public Integer changeArticle(Article article) {
        return articleMapper.updateArticle(article);
    }

    @Override
    public Integer addArticle(Article article) {
        return articleMapper.insertArticle(article);
    }

    @Override
    public Integer removeArticleById(Integer id) {
        return articleMapper.deleteArticleById(id);
    }


}
